import * as electron from 'electron'
import * as editor from './editor'
import { editorHistory } from './history';



export function run() {

    const template: electron.MenuItemConstructorOptions[] = [

        {
            label: "文件",
            submenu: [
                {
                    label: "保存",
                    accelerator: "CmdOrCtrl+S",
                    click: () => {
                        editor.save();
                   }
               }
           ] 
        },
        {
            label: 'Edit',
            submenu: [
                {
                    label: 'Undo',
                    accelerator: 'CmdOrCtrl+Z',
                    click: () => {
                        editorHistory.revertOnce();
                    }

                },
                {
                    label: 'Redo',
                    accelerator: 'Shift+CmdOrCtrl+Z',
                    click: () => {
                        editorHistory.redoOnce();
                    }

                },
            ]
        }

        
    ];

    var menu = electron.remote.Menu.buildFromTemplate(template);
    electron.remote.Menu.setApplicationMenu(menu);
}


export function changeTitle(str: string) {
    const title = document.getElementById("title");
    if (title) {
        title.innerText = "Hello,World!"
    }
}